Page({
  data: {
    houseId: "",
    userId: "",
    type: 0,
    selectedOptions: [], // 添加 selectedOptions 到 data 对象中
  },
  setReportMeaaage(selectedOptions) { // 接受 selectedOptions 作为参数
    const reportTypeIds = selectedOptions.map(option => option.value); // 提取 value 并转换为 Long 类型数组
    wx.request({
      url: 'http://localhost:8080/biz/reportrInformation',
      header: {
        'Authorization': 'Bearer ' + wx.getStorageSync('token')
      },
      data: {
        userHouseId: this.data.houseId,
        userId: this.data.userId,
        whoReport: this.data.type,
        reportTypeIds: reportTypeIds // 将 reportTypeIds 包含在数据中
      },
      method: 'POST',
      success(resp) {
        // console.log(resp);
      }
    });
  },

  onLoad(options) {
    // console.log(options);
    this.setData({
      type: parseInt(options.type, 10),
    });
    // console.log(this.data.type);
    const houseId = wx.getStorageSync('houseId');
    const userId = wx.getStorageSync('userId');
    if (houseId && userId) {
      this.setData({
        houseId: houseId,
        userId: userId,
      });
      // console.log(this.data.houseId);
      // console.log(this.data.userId);
    } else {
      wx.showToast({
        title: '参数错误',
        icon: 'none',
      });
    }
  },
});